﻿function AutoFillByKeywords(field, value) {
    if (field == "QQ") {
        $("#QQ").val(value);
    }
    if (field == "旺旺") {
        $("#Wangwang").val(value);
    }
    if (field == "绑定支付宝账号") {
        $("#ZhifubaoAccount").val(value);
    }
    if (field == "绑定支付宝账号姓名") {
        $("#ZhifubaoName").val(value);
    }
    if (field == "收款支付宝账号") {
        $("#RebateZhifubao").val(value);
    }
    if (field == "收款支付宝账号姓名") {
        $("#RebateZhifubaoName").val(value);
    }
    if (field == "电话") {
        $("#Cellphone").val(value);
    }
    if (field == "银行账号" || field == "旺旺绑定支付宝") {
        $("#BankAccount").val(value);
    }
    if (field == "银行户名" || field == "支付宝名字") {
        $("#BankName").val(value);
    }
    if (field == "何种银行") {
        $("#BankType").val(value);
    } if (field == "返款财付通") {
        $("#CaifutongAccount").val(value);
    } if (field == "旺旺绑定支付宝") {
        $("#ZhifubaoAccount").val(value);
    }
    if (field == "返款银行卡及户名") {
        $("#BankAccount").val(value);
    }
    if (field == "何种银行") {
        $("#BankType").val(value);
    }

}

//清空存在的值
function ClearExistVal() {
    $("#QQ").val("");
    $("#Wangwang").val("");
    $("#ZhifubaoAccount").val("");
    $("#ZhifubaoName").val("");
    $("#RebateZhifubao").val("");
    $("#RebateZhifubaoName").val("");
    $("#CaifutongAccount").val("");
    $("#CaifutongName").val("");
    $("#BankAccount").val("");
    $("#BankName").val("");
    $("#Source").val("");
    $("#Cash").val("");
    $("#Cellphone").val("");
    $("#Fixphone").val("");
    $("#ReceiveName").val("");
    $("#ReceiveAddress").val("");
    $("#ReceiveCellphone").val("");
    $("#ReceiveFixphone").val("");
    $("#beizhu").val("");
    $("#txtQQRelation").val("");
}

function setDisabled() {
    var cpf = $("#containsProFields").val();
    var containsProFields = $.parseJSON("{" + cpf + "}");
    if (containsProFields.QQ == "0") {
        $("input[name='QQ']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.Wangwang == "0") {
        $("input[name='Wangwang']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.ZhifubaoAccount == "0") {
        $("input[name='ZhifubaoAccount']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.ZhifubaoName == "0") {
        $("input[name='ZhifubaoName']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.RebateZhifubao == "0") {
        $("input[name='RebateZhifubao']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.RebateZhifubaoName == "0") {
        $("input[name='RebateZhifubaoName']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.CaifutongAccount == "0") {
        $("input[name='CaifutongAccount']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.CaifutongName == "0") {
        $("input[name='CaifutongName']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.ShopID == "0") {
        $("input[name='ShopID']").attr("disabled", "disabled").combobox({
            required: false
        });
    }
    if (containsProFields.Cash == "0") {
        $("input[name='Cash']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.Cellphone == "0") {
        $("input[name='Cellphone']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.Fixphone == "0") {
        $("input[name='Fixphone']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.ReceiveName == "0") {
        $("input[name='ReceiveName']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.ReceiveAddress == "0") {
        $("input[name='ReceiveAddress']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.ReceiveCellphone == "0") {
        $("input[name='ReceiveCellphone']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.ReceiveFixphone == "0") {
        $("input[name='ReceiveFixphone']").attr("disabled", "disabled").validatebox({
            required: false
        });
    }
    if (containsProFields.Date == "0") {

        $("#Date").datebox({
            required: false,
            disabled: true
        });

    }

    if (containsProFields.Address == "0") {
        $("#province").attr("disabled", "disabled");
        $("#city").attr("disabled", "disabled");
        $("#district").attr("disabled", "disabled");

    }


}


//定义grid的列定义
var cols = [[{
    field: 'ProID',
    title: "id",
    //    width: 40,
    sortable: true
}, {
    field: 'QQ',
    title: "QQ",
    //    width: 100,
    sortable: true,
    formatter: function (val, rec) {
        if ($('#chbQQ').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        } else {
            return val;
        }
    }
}, {
    field: 'QQRelation',
    title: "QQ关联",
    //    width: 100,
    sortable: true,
    formatter: function (val, rec) {
        return val;
    }
}, {
    field: 'CreatedBy',
    title: "录入者",
    //    width: 50,
    formatter: function (val, rec) {
        if ($('#chbwangwang').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        } else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'Wangwang',
    title: "旺旺",
    //    width: 120,
    formatter: function (val, rec) {
        if ($('#chbwangwang').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        } else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'BankName',
    title: "银行户名",
    //    width: 65,
    formatter: function (val, rec) {
        if ($('#chbBankName').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'BankAccount',
    title: "银行账号",
    //    width: 180,
    formatter: function (val, rec) {
        if ($('#chbBankAccount').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'BankType',
    title: "何种银行",
    width: 70,
    formatter: function (val, rec) {
        if ($('#chbBankType').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'Source',
    title: "来源",
    width: 100,
    formatter: function (val, rec) {
        if ($('#chbSource').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
},
{
    field: 'ShopName',
    title: "店铺名称",
    //    width: 60,
    formatter: function (val, rec) {
        var shops = val.split(',');
        if (shops.length > 1) {
            return '<span style="color:' + shops[1] + ';">' + shops[0] + '</span>';
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'Cash',
    title: "金额",
    //    width: 35,
    formatter: function (val, rec) {
        if ($('#chbCash').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'Date',
    title: "日期",
    //    width: 120,
    formatter: function (val, rec) {
        if ($('#chbDate').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'Beizhu',
    title: "备注",
    width: 200,
    formatter: function (val, rec) {
        if ($('#chbBeizhu').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'ZhifubaoAccount',
    title: "支付宝账户",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbZhifubao').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'ZhifubaoName',
    title: "支付宝名字",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbZhifubaoName').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'RebateZhifubao',
    title: "返款支付宝",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbRebateZhifubao').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'RebateZhifubaoName',
    title: "返款支付宝名字",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbRebateZhifubaoName').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'CaifutongAccount',
    title: "财付通账户",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbCaifutongAccount').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        } else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'CaifutongName',
    title: "财付通名字",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbCaifutongName').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        } else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'Cellphone',
    title: "手机",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbCellphone').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'Fixphone',
    title: "固定电话",
    //    width: 80,
    formatter: function (val, rec) {
        if ($('#chbFixphone').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'ReceiveName',
    title: "收货人",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbReceiveName').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'ReceiveAddress',
    title: "收货人详细地址",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbReceiveAddress').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'Province',
    title: "省",
    //    width: 30,
    formatter: function (val, rec) {
        if ($('#chbProvince').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'City',
    title: "市",
    //    width: 30,
    formatter: function (val, rec) {
        if ($('#chbCity').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
},

{
    field: 'District',
    title: "区",
    //    width: 30,
    formatter: function (val, rec) {
        if ($('#chbDistrict').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'ReceiveCellphone',
    title: "收货人手机",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbReceiveCellphone').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}, {
    field: 'ReceiveFixphone',
    title: "收货人固定电话",
    //    width: 100,
    formatter: function (val, rec) {
        if ($('#chbReceiveFixphone').attr("checked") == "checked" || hasChecked == false) {
            return LighterFont(val, $("#keyword").val());
        }
        else {
            return val;
        }
    },
    sortable: true
}

]];
